#include "mysql_connection.h"

#include "mysql_pool.h"

MySQLConnection::MySQLConnection(MySQLPool *pool, MySQLHandle *handle) : pool_(pool), handle_(handle)
{
}

MySQLConnection::~MySQLConnection()
{
    release();
}

void MySQLConnection::release()
{
    if (handle_ != nullptr) {
        pool_->release(handle_);
        handle_ = nullptr;
    }
}

void MySQLConnection::Create(const std::string &sql)
{
    handle_->Create(sql);
}

void MySQLConnection::Drop(const std::string &sql)
{
    handle_->Drop(sql);
}

uint64_t MySQLConnection::Insert(const std::string &sql)
{
    return handle_->Insert(sql);
}

void MySQLConnection::InsertList(const std::string &sql)
{
    handle_->InsertList(sql);
}

uint64_t MySQLConnection::Update(const std::string &sql)
{
    return handle_->Update(sql);
}

uint64_t MySQLConnection::Remove(const std::string &sql)
{
    return handle_->Remove(sql);
}

MySQLResult MySQLConnection::Select(const std::string &sql)
{
    return handle_->Select(sql);
}